import { request } from "../utils";
import type{addCompany, CompanyId, GetHistoryData, HistoryData}from '../types'
import type {CompanyList} from "../types";

// 添加企业申请单
export const addCompanyApi = (data:addCompany)=>{
  return request.post('/api/accounts',data)
}

// 获取企业申请单列表
export const getCompanyListApi = ()=>{
  return request.get<CompanyList[]>('/api/accounts')
}

// 修改企业信息
export const editCompanyItemApi =(id:string,params:CompanyId) =>{
  return request.put(`/api/accounts/${id}`,params)
}

// 删除企业信息
export const delCompanyItemApi = (id:string) =>{
  return request.delete(`/api/accounts/${id}`)
}

// 新增历史记录信息
export const addHistoryApi = (data:HistoryData)=>{
  return request.post('/history/company-history',data)
}

// 获取历史记录列表信息
export const getHistoryListApi = ()=>{
  return request.get<GetHistoryData>('/history/company-history')
}

export const downloadHistoryDocApi = (year:string,month:string,day:string)=>{
  // return request.get(`/history/generate-doc?year=${year}&month=${month}&day=${day}`,responseType:'blob')
  return request({
    method:'get',
    url:'/history/generate-doc',
    params:{
      year,month,day
    },
    responseType:'blob'
  })
}